/*
 *SRM 146 Div 2 Prob 3
 */

import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;


public class BridgeCrossing
{
    
    public int minTime(int[] times)
    {
	int n = times.length;
	int best = Integer.MAX_VALUE;
	if (n == 1)
	    return times[0];
	
	int[] d = new int[64];
	Arrays.fill (d, Integer.MAX_VALUE);
	d[0] = 0;
	LinkedList<Integer> ll = new LinkedList<Integer> ();
	ll.add (0);
	
	while (!ll.isEmpty ()) {
	    int l = ll.removeLast ();
	    for (int i = 0; i < n; ++i)
		if (((1<<i)&l) == 0) {
		    for (int j = i + 1; j < n; ++j)
			if (((1<<j) & l) == 0) {
			    int l1 = l;
			    l1 |= (1<<i);
			    l1 |= (1<<j);
			    int tmp = d[l] + Math.max (times[i], times[j]);
			    if (l1 == (1<<n)-1 && d[l1] > tmp)
				d[l1] = tmp;
			    
			    for (int k = 0; k < n; ++k)
				if (((1<<k) & l1) != 0) {
				    int l2 = l1 & (~(1<<k));
				    int tmp2 = tmp + times[k];
				    if (tmp2 < d[l2]) {
					d[l2] = tmp2;
					ll.add (l2);
				    }
				}
			}
		}
	}
	return d[(1<<n)-1];
	
    }
    

}
//Powered by KawigiEdit 2.1.4 (beta) modified by pivanof!